package org.stvd.common.security.filter;

import javax.servlet.http.HttpServletRequest;

import org.stvd.common.security.support.UserDetail;
import org.stvd.core.web.IPUtil;

class UserSessionThread extends Thread {
    private final UserDetail userDetail;
    private final HttpServletRequest request;

    public UserSessionThread(UserDetail userDetail, HttpServletRequest request) {
        this.userDetail = userDetail;
        this.request = request;
    }

    @Override
    public void run() {
        if ("".equals(userDetail.getIpAddress())) {
            String ipAddress = IPUtil.getIP(request);
            userDetail.setIpAddress(ipAddress);
            userDetail.setMacAddress(IPUtil.getMACAddress(ipAddress));
            userDetail.setHostName(IPUtil.getHostName(ipAddress));
        }
    }

}